package messageHandler;

import org.openymsg.network.Session;
import org.openymsg.network.Status;

import core.MessageBuilder;

public class LogInMessageHandler implements IMessage {

	@Override
	public Object Process(String message, Session session) {
		try {
			message = message.split(MessageBuilder.ONE)[1];
			String[] userInfo = message.split(MessageBuilder.TWO);
			boolean invisible = Boolean.parseBoolean(userInfo[2]);
			if (invisible) {
				session.setStatus(Status.INVISIBLE);
			}
			session.login(userInfo[0], userInfo[1]);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

}
